﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第九十六题
//BC98 BC98 序列中删除指定数字
//https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7?tpId=107&tqId=33379&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include<stdio.h>

int main() {
    int n = 0;
    scanf("%d", &n);
    // 开辟两个数组50个空间
    int arr1[50] = { 0 };
    int arr2[50] = { 0 };

    //存储数据
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr1[i]);
    }

    //输入指定数据
    int temp = 0;
    scanf("%d", &temp);

    //存储数据到第二个数组，是指定数据的就不拷贝
    int j = 0;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (arr1[i] != temp)
            arr2[j++] = arr1[i];
        else
            count++;
    }

    //打印数据
    for (int i = 0; i < n - count; i++) {
        printf("%d ", arr2[i]);
    }
    printf("\n");

    return 0;
}


//优化一下
#include<stdio.h>

int main() {
    int n = 0;
    int temp = 0;//指定删除的数据
    int j = 0;
    int arr1[50] = { 0 };
    int arr2[50] = { 0 };

    //输入整数
    scanf("%d", &n);

    //存储数据
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr1[i]);
    }

    //输入指定数据
    scanf("%d", &temp);

    //存储数据到第二个数组，是指定数据的就不拷贝
    for (int i = 0; i < n; i++) {
        if (arr1[i] != temp)
            arr2[j++] = arr1[i];
    }

    //打印数据
    for (int i = 0; i < n; i++) {
        if (arr2[i])
            printf("%d ", arr2[i]);
    }

    printf("\n");

    return 0;
}